package com.chazz.service.impl;

import com.chazz.dao.impl.AdressDaoImpl;
import com.chazz.entity.Adress;
import com.chazz.service.AdressService;

import java.sql.SQLException;
import java.util.List;

public class AdressServiceImpl implements AdressService {
    AdressDaoImpl adi=new AdressDaoImpl();
    @Override
    public boolean addAdress(int uid, String adress) {
        Adress adress1=new Adress();
        adress1.setUid(uid);
        adress1.setAdressvalue(adress);
        if(adi.addAdress(adress1)>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<Adress> showAdressList(int uid){
        try {
            return adi.findAllAdressByUid(uid);
        } catch (SQLException throwables) {
            return null;
        }
    }

    @Override
    public boolean deletAdress(int id) {
        Adress adress=new Adress();
        adress.setId(id);
        if(adi.deletAdress(adress)>0){
            return true;
        }else{
            return false;
        }

    }

    @Override
    public boolean updateAdress(int id,String adress) {
        Adress adress1=new Adress();
        adress1.setId(id);
        adress1.setAdressvalue(adress);
        if(adi.updateAdress(adress1)>0){
            return true;
        }else{
            return false;
        }
    }
}
